/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
 * GtkModelica
 * Copyright (C) Jorge Eduardo Cardona Gaviria 2008 <jorgeecardona@gmail.com>
 * 
 * GtkModelica is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * GtkModelica is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _BLOCKS_HPP_
#define _BLOCKS_HPP_

#include <gtkmm.h>
#include <libgdamm.h>

using namespace Glib::Markup;

#define PACKAGES_LIBRARY_PATH "library"

#define PACKAGE_INFO_FILE "package.info"
#define BLOCK_INFO_FILE "block.info"

#define PACKAGE_DEFAULT_DESCRIPTION "This package has no info file, please create one, at PACKAGE_PATH/.gtkmodelica.info"

class Blocks
{
public:
	Blocks();

	class Model_Record : public Gtk::TreeModelColumnRecord
	{
	public:
		Model_Record()
		{add(name); add(path); add(description); add(icon); add(is_block);}
		Gtk::TreeModelColumn< Glib::ustring >				name;
		Gtk::TreeModelColumn< Glib::ustring >				path;
		Gtk::TreeModelColumn< Glib::ustring >				description;
		Gtk::TreeModelColumn< Glib::RefPtr< Gdk::Pixbuf > > icon;
		Gtk::TreeModelColumn< bool >						is_block;
	};
	
	

	Model_Record	*model_record;
	Glib::RefPtr< Gtk::TreeStore >	tree_store;
		
	bool on_package(const Gtk::TreeModel::const_iterator& iter)
	{   return  not ((*iter)[model_record->is_block]); }
	
	bool on_block(const Gtk::TreeModel::const_iterator& iter)
	{   return (*iter)[model_record->is_block]; }
	
protected:

private:
	
	gint16  read_blocks(std::vector<Glib::ustring> filename, Gtk::TreeNodeChildren parent);
	
};



#endif // _BLOCKS_HPP_
